<?
if (!defined('baseinfo')) {
    exitdata();
}   


?>
<script src="<?=baseinfo?>/js/vendor/binaryajax.js"></script>
<script src="<?=baseinfo?>/js/vendor/exif.js"></script>
<script src="<?=baseinfo?>/js/vendor/canvasResize.js"></script>
<script src="<?=baseinfo?>/js/vendor/jquery.Jcrop.min.js"></script>
<script src="<?=baseinfo?>/js/vendor/jquery.iuploader-1.0.js"></script>
<script src="<?=baseinfo?>/js/vendor/jsuri-1.1.1.js"></script>

<script src="<?=baseinfo?>/js/coreadd.js"></script>
<link rel="stylesheet" href="<?=baseinfo?>/css/vendor/jcrop/jquery.Jcrop.min.css" type="text/css" />
<script>
$(document).ready(function(){
 $('input[name="levelstatus"]').change(function(){
   
   if($(this).val()=='2')
   {
   $('.gameMn.scndGameMn').show();
   }else
   {
   $('.gameMn.scndGameMn').hide();
   }
   
});
imageset('imgrule',1588,908,1588,908,'plgAreaRuleGm');
getallgamnification();








 });
var statussaveset=2;
var expconfig=<?if(count($data['expconfig'])){echo json_encode($data['expconfig']);}else{ echo "{}";}?>;
function imageset(rowgnowset,widthset,heightset,widthset2,heightset2,settarget)
{

var settargetset='imgBdgeGm';
if(settarget)
{
settargetset=settarget;
}
var rownow=1;
var rowgnow=rowgnowset;
 
 $('#feature'+rownow+' .image'+rowgnow+' .uploadbutton').iuploader({
         'link':serviceinfo+'iupload',
         'accept':'image/*',
         'group':rowgnow,

         'type':['jpg', 'jpeg', 'png', 'gif'],
         'onUploadFinish':function(filename,filelink,setting){
         
         
         
         
         getpopupboxresize(widthset,heightset,filelink,setting['originalwidth'],setting['originalheight'],
         
         function(filename2,filelink2,width2,height2,imgmid2){
         var rowgnow2=setting['group'];        
         $('#feature'+rownow+' .image'+rowgnow2+' .'+settargetset).html('<a target="_blank" href="'+filelink+'?t='+Math.floor((Math.random()*100000)+1)+'"><img height="'+heightset2+'" width="'+widthset2+'" src="'+filelink2+'?t='+Math.floor((Math.random()*100000)+1)+'"></a>');
         $('#feature'+rownow+' .image'+rowgnow2+' input[name="filelink[]"]').val(filelink);
         $('#feature'+rownow+' .image'+rowgnow2+' input[name="filelinkcrop[]"]').val(filelink2);                 
         $('#feature'+rownow+' .image'+rowgnow2+' input[name="fileold[]"]').val(setting.fileold);      
         $("#width-"+setting.id).val(setting.originalwidth);
         $("#height-"+setting.id).val(setting.originalheight);      
         $("#imgmid-"+setting.id).val(setting.imgmid);       
         $("#simgmid-"+setting.id).val(imgmid2);               
         $("#widthcrop-"+setting.id).val(width2);
         $("#heightcrop-"+setting.id).val(height2);    
         
          closepopup();  
         }
         ,setting['imgmid']
         
         );
         //alert(filename);
         }
   });
  
  
   $('#feature'+rownow+' .image'+rowgnow+' .cloudbutton').click(function() {
          //console.log("testdata");
          //var rowgnow3=rowgnow;
          var rowgnow3=rowgnowset;
        //alert("Handler for .click() called.");
          getpopupcloud(
          function(filename2,filelink2,width2,height2,imgmid2,index2){ 

        $('#feature'+rownow+' .image'+rowgnow3+' .'+settargetset).html('<a target="_blank" href="'+$('#feature'+rownow+' .image'+rowgnow3+' input[name="filelink[]"]').val()+'?t='+Math.floor((Math.random()*100000)+1)+'"><img height="'+heightset2+'" width="'+widthset2+'" src="'+filelink2+'?t='+Math.floor((Math.random()*100000)+1)+'"></a>');
         $('#feature'+rownow+' .image'+rowgnow3+' input[name="simgmid[]"]').val(imgmid2);
         $('#feature'+rownow+' .image'+rowgnow3+' input[name="filelinkcrop[]"]').val(filelink2);                                    
         $('#feature'+rownow+' .image'+rowgnow3+' input[name="widthcrop[]"]').val(width2);         
         $('#feature'+rownow+' .image'+rowgnow3+' input[name="heightcrop[]"]').val(height2);

        closepopup();  

          
          },
          
          
          function(filename,filelink,width,height,imgmid,indexnow){
            
            $('#feature'+rownow+' .image'+rowgnow3+' input[name="filelink[]"]').val(filelink);
            $('#feature'+rownow+' .image'+rowgnow3+' input[name="imgmid[]"]').val(imgmid);           
            $('#feature'+rownow+' .image'+rowgnow3+' input[name="width[]"]').val(width);
            $('#feature'+rownow+' .image'+rowgnow3+' input[name="height[]"]').val(height);
            

          
          }
          ,
          rowgnow
          ,widthset
          ,heightset
          
          );

   });
   
   $('#feature'+rownow+' .image'+rowgnow+'  .deletebutton').click(function() {
   
   var rowgnow3=rowgnowset;
   

   $('#feature'+rownow+' .image'+rowgnow3+' .'+settargetset+' a').remove();
   
   $('#feature'+rownow+' .image'+rowgnow3+' input[name="filelink[]"]').val('');
   $('#feature'+rownow+' .image'+rowgnow3+' input[name="imgmid[]"]').val('');           
   $('#feature'+rownow+' .image'+rowgnow3+' input[name="width[]"]').val('');
   $('#feature'+rownow+' .image'+rowgnow3+' input[name="height[]"]').val('');
   
   
   
    $('#feature'+rownow+' .image'+rowgnow3+' input[name="simgmid[]"]').val('');
     $('#feature'+rownow+' .image'+rowgnow3+' input[name="filelinkcrop[]"]').val('');                                    
     $('#feature'+rownow+' .image'+rowgnow3+' input[name="widthcrop[]"]').val('');         
     $('#feature'+rownow+' .image'+rowgnow3+' input[name="heightcrop[]"]').val('');
   
   });
   
   $('#feature'+rownow+' .image'+rowgnow+' .linkbutton').click(function() {
   var rowgnow3=rowgnowset;
   //console.log("test");
   
   getpopuplink(
          function(filename2,filelink2,width2,height2,imgmid2,index2){ 
          
          
         $('#feature'+rownow+' .image'+rowgnow3+' .'+settargetset).html('<a target="_blank" href="'+$('#feature'+rownow+' .image'+rowgnow3+' input[name="filelink[]"]').val()+'?t='+Math.floor((Math.random()*100000)+1)+'"><img height="'+heightset2+'" width="'+widthset2+'" src="'+filelink2+'?t='+Math.floor((Math.random()*100000)+1)+'"></a>');
         
         $('#feature'+rownow+' .image'+rowgnow3+' input[name="simgmid[]"]').val(imgmid2);
         $('#feature'+rownow+' .image'+rowgnow3+' input[name="filelinkcrop[]"]').val(filelink2);                                    
         $('#feature'+rownow+' .image'+rowgnow3+' input[name="widthcrop[]"]').val(width2);         
         $('#feature'+rownow+' .image'+rowgnow3+' input[name="heightcrop[]"]').val(height2);
        // $.colorbox.close("User added succesfully"); 
        closepopup();  
          
          },
          function(filename,filelink,width,height,imgmid,indexnow){
            

            $('#feature'+rownow+' .image'+rowgnow3+' input[name="filelink[]"]').val(filelink);
            $('#feature'+rownow+' .image'+rowgnow3+' input[name="imgmid[]"]').val(imgmid);           
            $('#feature'+rownow+' .image'+rowgnow3+' input[name="width[]"]').val(width);
            $('#feature'+rownow+' .image'+rowgnow3+' input[name="height[]"]').val(height);
            

          
          }
          ,
          rowgnow
          ,widthset
          ,heightset
   );
   
   });
   
    $('#feature'+rownow+' .image'+rowgnow+' .deleterowbutton').click(function(){
   
    $('#feature'+rownow).remove();

});

}
function changepagegame(pageset,statussave)
{
statussaveset=statussave;
$('.wrpInGameMn').hide();
$('.wrpInGameMn.'+pageset).show();

}
function savecheckdatagame()
{

savegamnificationfiter(statussaveset);
}
function savegamnificationfiter(statussavefilter)
{

var arrayobject={};
var wrong=0;
switch (statussavefilter) {
case 1:
arrayobject['fiter']=1;
arrayobject['status']=$('input[name="levelstatus"]:checked').val();
arrayobject['exp']=$('input[name="levelexp"]').val();
break;
case 2:
if($('input[name="levelstatus"]:checked').val()=='1')
{
wrong=1;
alertwrongboxmsgonly('Please Choose  Variable');

}else
{

if($('.gameMn.scndGameMn .bdInAddGameMn').length>0)
{
arrayobject['fiter']=2;
arrayobject['level']=new Array();
var krow=0;
$('.gameMn.scndGameMn .bdInAddGameMn').each(function( index ) {
arrayobject['level'][krow]={};
arrayobject['level'][krow]['levelid']=$(this).find('input[name="levelid[]"]').val();
if($(this).find('input[name="clevelname[]"]').val()!=''&&$(this).find('input[name="clevelexp[]"]').val()!=''&&$(this).find('input[name="imgmid[]"]').val()!='0'&&$(this).find('input[name="simgmid[]"]').val()!='0')
{
arrayobject['level'][krow]['name']=$(this).find('input[name="clevelname[]"]').val();
arrayobject['level'][krow]['exp']=$(this).find('input[name="clevelexp[]"]').val();
arrayobject['level'][krow]['imgmid']=$(this).find('input[name="imgmid[]"]').val();
arrayobject['level'][krow]['simgmid']=$(this).find('input[name="simgmid[]"]').val();
}else
{
wrong=1;
alertwrongboxmsgonly('Please Input Fill Empty');
return false;


}


krow++;

});
arrayobject['leveldelete']=deletelevel;
}else
{
wrong=1;
alertwrongboxmsgonly('Please Add  Level');

}

}


break;
case 3:
if($('.wrprBadgeMn .gameMn .bdInAddGameMn').length>0)
{
arrayobject['fiter']=3;
arrayobject['badge']=new Array();
var krow=0;
$('.wrprBadgeMn .gameMn .bdInAddGameMn').each(function( index ) {
arrayobject['badge'][krow]={};
arrayobject['badge'][krow]['badid']=$(this).find('input[name="badid[]"]').val();

if($(this).find('input[name="bname[]"]').val()!=''&&$(this).find('textarea[name="bdesc[]"]').val()!=''&&$(this).find('input[name="count[]"]').val()!=''&&$(this).find('select[name="gxcid[]"]').val()!=''&&$(this).find('.imgactivebadge input[name="imgmid[]"]').val()!='0'&&$(this).find('.imgactivebadge input[name="simgmid[]"]').val()!='0'&&$(this).find('.imgbadgebadge input[name="simgmid[]"]').val()!='0'&&$(this).find('.imgbadgebadge input[name="imgmid[]"]').val()!='0')
{
arrayobject['badge'][krow]['bname']=$(this).find('input[name="bname[]"]').val();
arrayobject['badge'][krow]['bdesc']=$(this).find('textarea[name="bdesc[]"]').val();
arrayobject['badge'][krow]['gxcid']=$(this).find('select[name="gxcid[]"]').val();
arrayobject['badge'][krow]['count']=$(this).find('input[name="count[]"]').val();
arrayobject['badge'][krow]['dimgmid']=$(this).find('.imgbadgebadge input[name="imgmid[]"]').val();
arrayobject['badge'][krow]['dsimgmid']=$(this).find('.imgbadgebadge input[name="simgmid[]"]').val();
arrayobject['badge'][krow]['aimgmid']=$(this).find('.imgactivebadge input[name="imgmid[]"]').val();
arrayobject['badge'][krow]['aimgsmid']=$(this).find('.imgactivebadge input[name="simgmid[]"]').val();
}else
{
wrong=1;
alertwrongboxmsgonly('Please Input Fill Empty');
return false;


}


krow++;

});
arrayobject['badgedelete']=deletebadge;
}else
{
wrong=1;
alertwrongboxmsgonly('Please Add  Badge');

}


break;

case 4:
arrayobject['fiter']=4;
arrayobject['gameexp']=new Array();
var krow=0;
$('.wrprEXPMn .createexpconfig .expconfiggamedata').each(function( index ) {
arrayobject['gameexp'][krow]={};
arrayobject['gameexp'][krow]['gxcid']=$(this).find('input[name="expgxcid[]"]').val();
arrayobject['gameexp'][krow]['exp']=$(this).find('input[name="expcountconfig[]"]').val();
krow++;

});
break;
case 5:
arrayobject['fiter']=5;
arrayobject['point']=$('input[name="pointconfig[]"]').val();

break;

case 6:
arrayobject['fiter']=6;
arrayobject['gamescore']=new Array();
if($('.wrprPlayerMn .plyerLst').length>0)
{
var krow=0;
$('.wrprPlayerMn .plyerLst').each(function( index ) {
arrayobject['gamescore'][krow]={};
arrayobject['gamescore'][krow]['point']=$(this).find('input[name="pointing[]"]').val();
arrayobject['gamescore'][krow]['userid']=$(this).find('input[name="useridgame[]"]').val();
krow++;

});

}else
{
wrong=1;
alertwrongboxmsgonly('Please Add  Player');

}
//arrayobject['point']=$('input[name="pointconfig[]"]').val();

break;

case 7:
arrayobject['fiter']=7;
if($('.wrpRuleMn input[name="imgmid[]"]').val())
{
arrayobject['rimgmid']=$('.wrpRuleMn input[name="imgmid[]"]').val();
arrayobject['rimgsmid']=$('.wrpRuleMn input[name="simgmid[]"]').val();

}else
{
wrong=1;
alertwrongboxmsgonly('Please Add  Image Role');
}
break;


}
if(wrong==0)
{
$.post(serviceinfo+'savegamnification', arrayobject, function(data) { 

alertrightboxmsgonly('Done');
checkgetall=0;
getallgamnification();
})
}


}
var idmorelevel=1;
function addmorelevel(levelid,clevelname,clevelexp,img,simg,imgmid,imgsmid)
{
var clevelnameset='';
if(clevelname)
{
clevelnameset=clevelname;
}

var clevelexpset='';
if(clevelexp)
{
clevelexpset=clevelexp;
}

var levelidset='';
if(levelid)
{
levelidset=levelid;
}


var imgset='';
if(img)
{
imgset=img;
}


var simgset='';
if(simg)
{
simgset=simg;
}

var imgmidset=0;
if(imgmid)
{
imgmidset=imgmid;
}


var imgsmidset=0;
if(imgsmid)
{
imgsmidset=imgsmid;
}
 
var code = '<div class="bdInAddGameMn clearfix" id="levelmore-'+idmorelevel+'">\n';
code += '<div class="ordGameMn">\n';
code += '<span>1.</span>\n';
code += '</div>\n';
code += '<div class="inpGameMn">\n';
code += '<div class="wrpInpGameMn lvlNmGm clearfix">\n';
code += '<span class="spnGmMn">Level Name</span>\n';
code += '<div class="inpGmMn">\n';
code += '<input type="text" name="clevelname[]" value="'+clevelnameset+'" class="inpTxtGameMn clBg5 clBd2 fs03 clTxt2">\n';
code += '</div>\n';
code += '</div>\n';
code += '<div class="wrpInpGameMn setIniEXPLvl clearfix">\n';
code += '<span class="spnGmMn">Initial EXP</span>\n';
code += '<div class="inpGmMn">\n';
code += '<input type="text" name="clevelexp[]" value="'+clevelexpset+'" class="inpTxtGameMn clBg5 clBd2 fs03 clTxt2">\n';

code += '<input type="hidden" name="levelid[]" value="'+levelidset+'" class="inpTxtGameMn clBg5 clBd2 fs03 clTxt2">\n';

code += '</div>\n';
code += '</div>\n';

code += '<div class="wrpInpGameMn lvlBdgeGm clearfix" id="feature1">\n';
code += '<span class="spnGmMn">Level Badge</span>\n';
code += '<div class="wrpBdgeGmMn image'+idmorelevel+'">\n';
code += '<div class="imgBdgeGm clBd2 clBg4 bdFull"></div>\n';
code += '<div class="addTnTl clBd2 bdBtm">\n';
code += '<div title="Browse" class="btnIco addImgTl clBd3 bdBtm uploadbutton">\n';
code += '<span class="ico icoAddImgTl"></span>\n';
code += '<div class="wrpUlFile">\n';

code += '</div>\n';
code += '</div>\n';
code += '<div title="Cloud" class="btnIco addCldTl clBd3 bdBtm cloudbutton">\n';
code += '<span class="ico icoAddCldTl"></span>\n';
code += '</div>\n';
code += '<div title="Link" class="btnIco addLnkTl clBd3 bdBtm linkbutton">\n';
code += '<span class="ico icoAddLnkTl"></span>\n';
code += '</div>\n';
code += '<div title="Remove" class="btnIco btnRmvTl deletebutton">\n';
code += '<span class="ico icoRmvTl"></span>\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>\n';
code += '<div class="wrpRmvGmMn">\n';
code += '<div class="rmvGmMn clBgBt1">\n';
code += '<button class="clTxtW clBgBt1 fs04" type="button" onclick="removelevel('+idmorelevel+')">Remove This Level</button>\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>';

$('.creategamilevel').append(code);

imageset(idmorelevel,600,600,150,150);
$('#levelmore-'+idmorelevel+' input[name="imgmid[]"]').val(imgmidset);
$('#levelmore-'+idmorelevel+' input[name="simgmid[]"]').val(imgsmidset);
if(imgset)
{

$('#levelmore-'+idmorelevel+' .imgBdgeGm').html('<a href="'+imgset+'" target="_blank"><img width="150" height="150" src="'+simgset+'"></a>');
}



idmorelevel++;
var numrow=1;
$('.wrprLevelMn .bdInAddGameMn .ordGameMn span').each(function( index ) {
 $(this).html(numrow+'.');
 numrow++;


});

}
var deletelevel=new Array();
var deletebadge=new Array();
var krowdelete=0;
var krowbadgedelete=0;
function removelevel(idmorelevelset)
{
if($('#levelmore-'+idmorelevelset+' input[name="levelid[]"]').val()!='')
{
deletelevel[krowdelete]=$('#levelmore-'+idmorelevelset+' input[name="levelid[]"]').val();
krowdelete++;

}

$('#levelmore-'+idmorelevelset).remove();

var numrow=1;
$('.wrprLevelMn .bdInAddGameMn .ordGameMn span').each(function( index ) {
 $(this).html(numrow+'.');
 numrow++;
//console.log( index + ": " + $( this ).text() );

});

}
function removethisbadge(idmorebadgeset)
{
if($('#badgemore-'+idmorebadgeset+' input[name="badid[]"]').val()!='')
{
deletebadge[krowbadgedelete]=$('#badgemore-'+idmorebadgeset+' input[name="badid[]"]').val();
krowbadgedelete++;

}

$('#badgemore-'+idmorebadgeset).remove();

var numrow=1;
$('.wrprBadgeMn .bdInAddGameMn .ordGameMn span').each(function( index ) {
 $(this).html(numrow+'.');
 numrow++;
//console.log( index + ": " + $( this ).text() );

});

}
var checkgetall=1;
var searchtext='';
function searchBox()
{
searchtext=$('#srchBoxdata').val();
var param1,param2,param3;
loaduserlistgame(1,param1,param2,param3)

}
function getallgamnification()
{

$.get(serviceinfo+'getallgamnification',{searchtext:searchtext}, function(data) { 
if(statussaveset==2||checkgetall==1)
{
$('.creategamilevel').html('');
deletelevel=new Array();
krowdelete=0;

if(data.data.exp.gexpsid)
{
  $('input[name="levelstatus"]').filter('[value='+data.data.exp.status+']').prop('checked', true);
    if(data.data.exp.status=='2')
   {
   
   $('.gameMn.scndGameMn').show();
   }else
   {
   $('.gameMn.scndGameMn').hide();
   $('input[name="levelexp"]').val(data.data.exp.exp);
   }
   
   if(data.data.explevel.length)
   {
    $.each(data.data.explevel, function(key, value) {
    addmorelevel(value.levelid,value.name,value.exp,baseinfo+'/'+value.pathimg,baseinfo+'/'+value.pathsimg,value.imgmid,value.simgmid);
    });
   
   }
 



 
 }else
{


}

}

 if(statussaveset==3||checkgetall==1)
{
$('.creategambadge').html('');
deletebadge=new Array();
krowbadgedelete=0;
if(data.data.badge.length)
{
 $.each(data.data.badge, function(key, value) {
    addbadgelevel(value.badid,value.bname,value.bdesc,value.gxcid,value.count,baseinfo+'/'+value.dimg,baseinfo+'/'+value.dsimg,value.dimgmid,value.dsimgmid,baseinfo+'/'+value.aimg,baseinfo+'/'+value.asimg,value.aimgmid,value.aimgsmid);
    });
}


}

 if(statussaveset==4||checkgetall==1)
 {
 $('.createexpconfig').html('');
 var rowh=1;
 if(data.data.expconfig.length)
{
 var code ='';
 $.each(data.data.expconfig, function(key, value) {
 
code += '<div class="bdInAddGameMn clearfix expconfiggamedata">\n';
code += '<div class="inpGameMn">\n';
code += '<div class="wrpInpGameMn EXPNmGm clearfix">\n';
code += '<span class="spnGmMn">'+rowh+'. 1 '+value.name+'</span>\n';
code += '<div class="inpGmMn">\n';
code += '<span class="spnInpGmMn1">=</span>\n';
code += '<input type="text" name="expcountconfig[]" value="'+value.exp+'" class="inpTxtGameMn clBg5 clBd2 fs03 clTxt2">\n';
code += '<input type="hidden" name="expgxcid[]" value="'+value.gxcid+'" class="inpTxtGameMn clBg5 clBd2 fs03 clTxt2">\n';
code += '<span class="spnInpGmMn2">EXP</span>\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>';

rowh++;
 
 });
 
  $('.createexpconfig').html(code);

}
 
 }
 
  if(statussaveset==5||checkgetall==1)
  {
  if(data.data.exp.gexpsid)
    {
    
    $('input[name="pointconfig[]"]').val(data.data.exp.point);

    }
  
  }
  
 if(statussaveset==6||checkgetall==1)
 {
     $('#pagePlyer').html('');   
     
     if(data.data.userlist.data.length)
     {
     getuserlistgame(data.data.userlist.data);
     var param1,param2,param3;
     setpaginationnoreverse('#pagePlyer',data.data.userlist.page,12,'loaduserlistgame',param1,param2,param3);
     
     }
 
 }
 
  if(statussaveset==7||checkgetall==1)
  {
  
$('.wrpRuleMn  input[name="imgmid[]"]').val(data.data.exp.rimgmid);
$('.wrpRuleMn  input[name="simgmid[]"]').val(data.data.exp.rimgsmid);
if(data.data.exp.pathimg)
{

$('.wrpRuleMn .plgAreaRuleGm').html('<a href="'+baseinfo+'/'+data.data.exp.pathimg+'" target="_blank"><img width="1588" height="908" src="'+baseinfo+'/'+data.data.exp.pathsimg+'"></a>');

}


  
  }


});

}
function loaduserlistgame(pageset,param1,param2,param3)
{
$.get(serviceinfo+'getgameuserlist',{page:pageset,searchtext:searchtext}, function(data) { 

if(data.data.userlist.data.length)
     {
getuserlistgame(data.data.userlist.data);
     }
     if(pageset==1)
     {
     setpaginationnoreverse('#pagePlyer',data.data.userlist.page,12,'loaduserlistgame',param1,param2,param3);
     
     }

});

}
var rowuserlistgame=1;
function getuserlistgame(userlist)
{
var code='';
var rnum=1;

 $.each(userlist, function(key, value) {
 
code += '<div class="plyerLst clBd2 bdBtm clearfix" id="gameuserlistset-'+rowuserlistgame+'">\n';
code += '<div class="ordPlyer clearfix">\n';
code += '<span>'+rnum+'.</span>\n';
code += '</div>\n';
code += '<div class="nmePlyer clearfix">\n';
code += '<a class="clearfix" href="'+baseinfo+'/'+value.username+'">\n';
code += '<img width="24" height="24" alt="img" src="'+baseinfo+'/'+value.imgpath+'" class="genImgUser">\n';
code += '<span class="cutTxt">'+value.displayname+'</span>\n';
code += '</a>\n';
code += '</div>\n';
code += '<div class="lvlPlyer clearfix">\n';
if(value.levelset.name)
{
code += '<span>'+value.levelset.name+'</span>\n';
}else
{
code += '<span>'+value.level+'</span>\n';

}




code += '</div>\n';
code += '<div class="EXPPlyer clearfix">\n';
code += '<span>'+value.exp+'</span>\n';
code += '</div>\n';
code += '<div class="pntPlyer clearfix">\n';
code += '<span>'+value.point+'</span>\n';
code += '</div>\n';
code += '<div class="addPntPlyer">\n';
code += '<button class="btnPntPlyer clTxtW clBgBt1 fs04" onclick="openpopupgameuserlist('+rowuserlistgame+')">+ Point</button>\n';
code += '<div class="wrpPopPntPlyer">\n';
code += '<div class="triGame"></div>\n';
code += '<div class="wrpInPopPntPlyer clBg5 clBd2 bdFull">\n';
code += '<div class="popPntPlyer">\n';
code += '<span>Number of Point</span>\n';
code += '<input type="text" name="pointing[]" value="'+value.point+'" class="inpTxtGameMn clBg5 clBd2 fs03 clTxt2">\n';
code += '<input type="hidden" name="useridgame[]" value="'+value.userid+'" class="inpTxtGameMn clBg5 clBd2 fs03 clTxt2">\n';
code += '<button class="clTxtW clBgBt1 fs04" onclick="presaveuserlistgame('+rowuserlistgame+')">Submit</button>\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>';
rowuserlistgame++;
rnum++;
 });
 
 $('.bdPlyerLst').html(code);

}
function openpopupgameuserlist(rowuserlistgameset)
{
$('#gameuserlistset-'+rowuserlistgameset+' .wrpPopPntPlyer').show();


}

function presaveuserlistgame(rowuserlistgameset)
{
if($('#gameuserlistset-'+rowuserlistgameset+' input[name="pointing[]"]').val())
{
var pointing=$('#gameuserlistset-'+rowuserlistgameset+' input[name="pointing[]"]').val();

$('#gameuserlistset-'+rowuserlistgameset+' .pntPlyer').html(pointing);

$('#gameuserlistset-'+rowuserlistgameset+' .wrpPopPntPlyer').hide();
}else
{

alertwrongboxmsgonly('Please Add  Point');
}


}


//var idmorebadgelevel=1;
function addbadgelevel(badid,bname,bdesc,gxcid,count,dimg,dsimg,dimgmid,dsimgmid,aimg,asimg,aimgmid,aimgsmid)
{



var dimgset='';
if(dimg)
{
dimgset=dimg;
}

var dsimgset='';
if(dsimg)
{
dsimgset=dsimg;
}

var aimgset='';
if(aimg)
{
aimgset=aimg;
}

var asimgset='';
if(asimg)
{
asimgset=asimg;
}


var badidset='';
if(badid)
{
badidset=badid;
}

var bnameset='';
if(bname)
{
bnameset=bname;
}

var bdescset='';
if(bdesc)
{
bdescset=bdesc;
}

var gxcidset='';
if(gxcid)
{
gxcidset=''+gxcid;
}

var countset='';
if(count)
{
countset=count;
}

var dimgmidset=0;
if(dimgmid)
{
dimgmidset=dimgmid;
}

var dsimgmidset=0;
if(dsimgmid)
{
dsimgmidset=dsimgmid;
}

var aimgmidset=0;
if(aimgmid)
{
aimgmidset=aimgmid;
}

var aimgsmidset=0;
if(aimgsmid)
{
aimgsmidset=aimgsmid;
}

var code = '<div class="bdInAddGameMn clearfix" id="badgemore-'+idmorelevel+'">\n';
code += '<div class="ordGameMn">\n';
code += '<span>2.</span>\n';
code += '</div>\n';
code += '<div class="inpGameMn" id="feature1">\n';
code += '<div class="wrpInpGameMn bdgeNmGm clearfix">\n';
code += '<span class="spnGmMn">Badge Name</span>\n';
code += '<div class="inpGmMn">\n';
code += '<input type="text" name="bname[]" value="'+bnameset+'" class="inpTxtGameMn clBg5 clBd2 fs03 clTxt2">\n';
code += '</div>\n';
code += '</div>\n';
code += '<div class="wrpInpGameMn bdgeDes clearfix">\n';
code += '<span class="spnGmMn">Badge Description <em class="fs03">(limited to 30 characters)</em></span>\n';
code += '<div class="inpGmMn">\n';
code += '<textarea type="text" name="bdesc[]"  class="inpTxtGameMn clBg5 clBd2 fs03 clTxt2" maxlength="30">'+bdescset+'</textarea>\n';
code += '</div>\n';
code += '</div>\n';
code += '<div class="wrpInpGameMn bdgeType clearfix">\n';
code += '<span class="spnGmMn">Badge Type</span>\n';
code += '<div class="reDesign slctGmMn">\n';

code += '<input type="hidden" name="badid[]" value="'+badidset+'" class="inpTxtGameMn clBg5 clBd2 fs03 clTxt2">\n';

code += '<select name="gxcid[]" >\n';

$.each( expconfig, function( key, value ) {
if(gxcidset==value.gxcid)
{
code += '<option selected="selected" value="'+value.gxcid+'">'+value.name+'</option>\n';

}else
{
code += '<option value="'+value.gxcid+'">'+value.name+'</option>\n';
}

//alert( key + ": " + value );


});



//code += '<option value="like">like</option>\n';
//code += '<option value="bookmark">bookmark</option>\n';
//code += '<option value="following">following</option>\n';
//code += '<option value="follower">follower</option>\n';
//code += '<option value="share">share</option>\n';
//code += '<option value="message">message</option>\n';
//code += '<option value="comment">comment</option>\n';
//code += '<option value="join">join</option>\n';
//code += '<option value="create post">create post</option>\n';


code += '</select>\n';

code += '</div>\n';
code += '</div>\n';
code += '<div class="wrpInpGameMn bdgeNum clearfix">\n';
code += '<span class="spnGmMn">Number of Activity to Achieve</span>\n';
code += '<div class="inpGmMn">\n';
code += '<input type="text" name="count[]" value="'+countset+'" class="inpTxtGameMn clBg5 clBd2 fs03 clTxt2">\n';
code += '</div>\n';
code += '</div>\n';
code += '<div class="wrpInpGameMn bdgeAct clearfix" >\n';
code += '<span class="spnGmMn">Default Activity Badge</span>\n';
code += '<div class="wrpBdgeGmMn imgbadgebadge image'+idmorelevel+'">\n';
code += '<div class="imgBdgeGm clBd2 clBg4 bdFull"></div>\n';
code += '<div class="addTnTl clBd2 bdBtm">\n';
code += '<div class="btnIco addImgTl clBd3 bdBtm uploadbutton" title="Browse">\n';
code += '<span class="ico icoAddImgTl"></span>\n';
code += '<div class="wrpUlFile">\n';
idmorelevel++;
//code += '<input type="file" class="ulFile">\n';
code += '</div>\n';
code += '</div>\n';
code += '<div class="btnIco addCldTl clBd3 bdBtm cloudbutton" title="Cloud">\n';
code += '<span class="ico icoAddCldTl"></span>\n';
code += '</div>\n';
code += '<div class="btnIco addLnkTl clBd3 bdBtm linkbutton" title="Link">\n';
code += '<span class="ico icoAddLnkTl"></span>\n';
code += '</div>\n';
code += '<div class="btnIco btnRmvTl deletebutton" title="Remove">\n';
code += '<span class="ico icoRmvTl"></span>\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>\n';
code += '<div class="wrpInpGameMn bdgeAct clearfix">\n';
code += '<span class="spnGmMn">Active Activity Badge</span>\n';
code += '<div class="wrpBdgeGmMn imgactivebadge image'+idmorelevel+'">\n';
code += '<div class="imgBdgeGm clBd2 clBg4 bdFull"></div>\n';
code += '<div class="addTnTl clBd2 bdBtm">\n';
code += '<div class="btnIco addImgTl clBd3 bdBtm uploadbutton" title="Browse">\n';
code += '<span class="ico icoAddImgTl"></span>\n';
code += '<div class="wrpUlFile">\n';
//code += '<input type="file" class="ulFile">\n';
code += '</div>\n';
code += '</div>\n';
code += '<div class="btnIco addCldTl clBd3 bdBtm cloudbutton" title="Cloud">\n';
code += '<span class="ico icoAddCldTl"></span>\n';
code += '</div>\n';
code += '<div class="btnIco addLnkTl clBd3 bdBtm linkbutton" title="Link">\n';
code += '<span class="ico icoAddLnkTl"></span>\n';
code += '</div>\n';
code += '<div class="btnIco btnRmvTl deletebutton" title="Remove">\n';
code += '<span class="ico icoRmvTl"></span>\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>\n';
code += '<div class="wrpRmvGmMn">\n';
code += '<div class="rmvGmMn clBgBt1">\n';
idmorelevel--;
code += '<button onclick="removethisbadge('+idmorelevel+')" class="clTxtW clBgBt1 fs04">Remove This Badge</button>\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>';
var nowmorelevel=idmorelevel;
nowmorelevel++;
var nowmorelevel2=idmorelevel;
idmorelevel++;
idmorelevel++;
idmorelevel++;

$('.creategambadge').append(code);

imageset(nowmorelevel,600,600,150,150);


if(aimgset)
{

$('#badgemore-'+nowmorelevel2+' .imgactivebadge input[name="imgmid[]"]').val(aimgmidset);
$('#badgemore-'+nowmorelevel2+' .imgactivebadge input[name="simgmid[]"]').val(aimgsmidset);
$('#badgemore-'+nowmorelevel2+' .imgactivebadge .imgBdgeGm').html('<a href="'+aimgset+'" target="_blank"><img width="150" height="150" src="'+asimgset+'"></a>');
}

nowmorelevel--;
imageset(nowmorelevel,600,600,150,150);

$('#badgemore-'+nowmorelevel2+' .imgbadgebadge input[name="imgmid[]"]').val(dimgmidset);
$('#badgemore-'+nowmorelevel2+' .imgbadgebadge input[name="simgmid[]"]').val(dsimgmidset);
if(dimgset)
{

$('#badgemore-'+nowmorelevel2+' .imgbadgebadge .imgBdgeGm').html('<a href="'+dimgset+'" target="_blank"><img width="150" height="150" src="'+dsimgset+'"></a>');

}


var numrow=1;
$('.wrprBadgeMn .bdInAddGameMn .ordGameMn span').each(function( index ) {
 $(this).html(numrow+'.');
 numrow++;


});




}




</script>



